//
//package net.lab0.fractal.gui;
//
//
//import java.awt.BorderLayout;
//import java.awt.Dimension;
//import java.awt.GridBagConstraints;
//import java.awt.GridBagLayout;
//import java.awt.Insets;
//import java.util.concurrent.Future;
//import java.util.concurrent.ThreadPoolExecutor;
//
//import javax.swing.JFrame;
//import javax.swing.JLabel;
//import javax.swing.JPanel;
//import javax.swing.border.TitledBorder;
//
//import net.lab0.fractal.concurrent.MainThreadPoolExecutor;
//import net.lab0.fractal.fractals.mandelbrot.MandelbrotQuadTreeZoneInfo;
//import net.lab0.tools.quadtree.QuadTreeNode;
//
//import org.jfree.chart.ChartFactory;
//import org.jfree.chart.ChartPanel;
//import org.jfree.chart.JFreeChart;
//import org.jfree.chart.axis.NumberAxis;
//import org.jfree.chart.plot.CategoryPlot;
//import org.jfree.chart.plot.PlotOrientation;
//import org.jfree.data.category.DefaultCategoryDataset;
//
//
//@SuppressWarnings("serial")
//public class MandelbrotZoneInformationFrame
//extends JFrame
//{
//    private final JLabel     lblZone         = new JLabel("");
//    private final JPanel     panel           = new JPanel();
//    private final JPanel     panel_1         = new JPanel();
//    private final JLabel     lblNewLabel     = new JLabel("Path");
//    private final JLabel     lblNewLabel_1   = new JLabel("MinIter");
//    private final JLabel     lblMaxiter      = new JLabel("MaxIter");
//    private final JLabel     lblPathValue    = new JLabel("4");
//    private final JLabel     lblMinitervalue = new JLabel("MinIterValue");
//    private final JLabel     lblMaxitervalue = new JLabel("MaxIterValue");
//    private final ChartPanel chartPanel      = new ChartPanel((JFreeChart) null);
//    
//    public MandelbrotZoneInformationFrame(QuadTreeNode<QuadTreeElementInterface, MandelbrotQuadTreeZoneInfo> node)
//    {
//        initComponents();
//        graph(node);
//        lblPathValue.setText(node.getPath());
//        MandelbrotQuadTreeZoneInfo info = node.getNodeElement();
//        if (info != null)
//        {
//            lblMinitervalue.setText("" + info.getMinIter());
//            lblMaxitervalue.setText("" + info.getMaxIter());
//        }
//    }
//    
//    private void graph(QuadTreeNode<QuadTreeElementInterface, MandelbrotQuadTreeZoneInfo> node)
//    {
//        final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
//        
//        int iter = 1024;
//        MandelbrotZoneTest test = new MandelbrotZoneTest(node, iter, 1000, 100);
//        ThreadPoolExecutor executor = MainThreadPoolExecutor.getInstance();
//        Future<MandelbrotZoneTestInterface> future = executor.submit(test);
//        MandelbrotZoneTestInterface result;
//        try
//        {
//            result = future.get();
//            int col = 0;
//            System.out.println(result.getDistribution().length);
//            for (int i : result.getDistribution())
//            {
//                dataset.addValue(Math.sqrt(i), "" + col, "" + iter);
//                col++;
//            }
//            
//            final JFreeChart chart = ChartFactory.createBarChart("Max=" + result.getMaxComputed(), null, null, dataset, PlotOrientation.VERTICAL, false, false, false);
//            CategoryPlot plot = (CategoryPlot) chart.getPlot();
//            NumberAxis axis = (NumberAxis) plot.getRangeAxis();
//            axis.setVisible(false);
//            chartPanel.setChart(chart);
//        }
//        catch (Exception e)
//        {
//            e.printStackTrace();
//        }
//    }
//    
//    private void initComponents()
//    {
//        getContentPane().setLayout(new BorderLayout(0, 0));
//        
//        getContentPane().add(panel_1, BorderLayout.CENTER);
//        GridBagLayout gbl_panel_1 = new GridBagLayout();
//        gbl_panel_1.columnWidths = new int[] { 0, 300, 0 };
//        gbl_panel_1.rowHeights = new int[] { 0, 0, 0, 0, 0 };
//        gbl_panel_1.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE };
//        gbl_panel_1.rowWeights = new double[] { 0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE };
//        panel_1.setLayout(gbl_panel_1);
//        GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
//        gbc_lblNewLabel.insets = new Insets(0, 0, 5, 5);
//        gbc_lblNewLabel.gridx = 0;
//        gbc_lblNewLabel.gridy = 0;
//        panel_1.add(lblNewLabel, gbc_lblNewLabel);
//        
//        GridBagConstraints gbc_lblPathValue = new GridBagConstraints();
//        gbc_lblPathValue.anchor = GridBagConstraints.WEST;
//        gbc_lblPathValue.insets = new Insets(0, 0, 5, 0);
//        gbc_lblPathValue.gridx = 1;
//        gbc_lblPathValue.gridy = 0;
//        panel_1.add(lblPathValue, gbc_lblPathValue);
//        
//        GridBagConstraints gbc_lblNewLabel_1 = new GridBagConstraints();
//        gbc_lblNewLabel_1.insets = new Insets(0, 0, 5, 5);
//        gbc_lblNewLabel_1.gridx = 0;
//        gbc_lblNewLabel_1.gridy = 1;
//        panel_1.add(lblNewLabel_1, gbc_lblNewLabel_1);
//        
//        GridBagConstraints gbc_lblMinitervalue = new GridBagConstraints();
//        gbc_lblMinitervalue.anchor = GridBagConstraints.WEST;
//        gbc_lblMinitervalue.insets = new Insets(0, 0, 5, 0);
//        gbc_lblMinitervalue.gridx = 1;
//        gbc_lblMinitervalue.gridy = 1;
//        panel_1.add(lblMinitervalue, gbc_lblMinitervalue);
//        
//        GridBagConstraints gbc_lblMaxiter = new GridBagConstraints();
//        gbc_lblMaxiter.insets = new Insets(0, 0, 5, 5);
//        gbc_lblMaxiter.gridx = 0;
//        gbc_lblMaxiter.gridy = 2;
//        panel_1.add(lblMaxiter, gbc_lblMaxiter);
//        
//        GridBagConstraints gbc_lblMaxitervalue = new GridBagConstraints();
//        gbc_lblMaxitervalue.anchor = GridBagConstraints.WEST;
//        gbc_lblMaxitervalue.insets = new Insets(0, 0, 5, 0);
//        gbc_lblMaxitervalue.gridx = 1;
//        gbc_lblMaxitervalue.gridy = 2;
//        panel_1.add(lblMaxitervalue, gbc_lblMaxitervalue);
//        
//        GridBagConstraints gbc_chartPanel = new GridBagConstraints();
//        gbc_chartPanel.gridwidth = 2;
//        gbc_chartPanel.fill = GridBagConstraints.BOTH;
//        gbc_chartPanel.gridx = 0;
//        gbc_chartPanel.gridy = 3;
//        chartPanel.setBorder(new TitledBorder(null, "Distribution", TitledBorder.LEADING, TitledBorder.TOP, null, null));
//        chartPanel.setPreferredSize(new Dimension(100, 100));
//        panel_1.add(chartPanel, gbc_chartPanel);
//    }
//}
